/*
 *company:jlc
 *author:xudd
 *date:2020/5/12:11:17
 *desc:{}
 **/


package com.crazymakercircle.redis.jedis.cluster;

import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;

import java.util.HashSet;
import java.util.Set;

/**
 * @author:xudd
 * @date:2020/5/12 -11:17
 * @desc:
 **/
public class JedisClusterUtils {

    public static JedisCluster getJedisCluster(){

        Set<HostAndPort> nodes = new HashSet<>();
        nodes.add(new HostAndPort("182.254.175.84", 7000));
        nodes.add(new HostAndPort("182.254.175.84", 7001));
        nodes.add(new HostAndPort("203.195.130.237", 7000));
        nodes.add(new HostAndPort("203.195.130.237", 7001));
        nodes.add(new HostAndPort("203.195.134.101", 7000));
        nodes.add(new HostAndPort("203.195.134.101", 7001));
        JedisCluster cluster = new JedisCluster(nodes);

        return cluster;

    }

    public static void main(String[] args) {
        JedisCluster cluster=  getJedisCluster();

        try {
            cluster.set("name", "LBG");
            String res = cluster.get("name");
            System.out.println(res);
            cluster.close();
        } catch (Exception e) {
            e.printStackTrace();
            cluster.close();
        }
    }

}
